import {request} from "../../request/index.js"

Page({

  /**
   * 页面的初始数据
   */
  data: {
      notInWareHouseList:null,
      show1: true,
      show2: true,
      length: 0,
      point: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var user=wx.getStorageSync('user')
    if(user == ""){
      wx.showToast({
        title: '请先登录',
        icon: 'success',
        image: '../images/warning.png',
        duration: 2000
      })
      setTimeout(function () {
        wx.switchTab({
          url: '../login/login',
        })
      }, 2000)
    }else{
      console.log("success")
    }
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var user=wx.getStorageSync('user')
    if(user == ""){
      wx.showToast({
        title: '请先登录',
        icon: 'success',
        image: '../images/warning.png',
        duration: 2000
      })
      setTimeout(function () {
        wx.switchTab({
          url: '../login/login',
        })
      }, 2000)
    }else{
      console.log("success")
    }


    var that = this

    wx.request({
      url: 'http://180.169.75.246:18090/wire/wire/list/inspect',
      data:{
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success:function(res){
        that.setData({
          length: res.data.length
        })
      }
    })

    request({
      url: "/wire/list/inspect", 
      data: {
      }, 
      header: {
        'content-type': 'application/json' // 默认值
      }
    })
    .then(res => {
      that.setData({
        length: res.data.length
      })
    })

    request({
      url: "/countWireUsing", 
      data: {
      }, 
      header: {
        'content-type': 'application/json' // 默认值
      }
    })
    .then(res => {
      var point = res.data
      this.setData({
        point
      })
    })
  },
  //新增使用者
  addUser:function(){
    wx.navigateTo({
      url: '../addManager/addManager',
    })
  },
  addPoint:function(){
    wx.navigateTo({
      url: '../addPoint/addPoint',
    })
  },
  addWire:function(){
    wx.navigateTo({
      url: '../chooseWire/chooseWire',
    })
  },
  //查看不在仓库中的接地线
  findNoWareHouse:function(e){
    wx.navigateTo({
      url: '../chooseUser/chooseUser',
    })
  },
  //查看在仓库中的接地线，首先跳转到选择仓库页面
  findInWareHouse:function(e){
      wx.navigateTo({
        url: '../choose/choose',
      })
  },
  findWireByPoint:function(){
    wx.navigateTo({
      url: '../choosePoint/choosePoint',
    })
  }
})